package com.xjy.system.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xjy.common.core.mybatisplus.core.ServicePlusImpl;
import com.xjy.common.core.page.PagePlus;
import com.xjy.common.core.page.TableDataInfo;
import com.xjy.common.utils.PageUtils;
import com.xjy.system.domain.ReportPrepaymentDetail;
import com.xjy.system.domain.ReportPrepaymentRecord;
import com.xjy.system.domain.bo.ReportPrepaymentRecordQueryBo;
import com.xjy.system.domain.vo.ReportPrepaymentRecordVo;
import com.xjy.system.mapper.ReportPrepaymentRecordMapper;
import com.xjy.system.service.IReportPrepaymentRecordService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 归还冲销记录Service业务层处理
 *
 * @author mlb
 * @date 2022-03-24
 */
@Service
public class ReportPrepaymentRecordServiceImpl extends ServicePlusImpl<ReportPrepaymentRecordMapper, ReportPrepaymentRecord> implements IReportPrepaymentRecordService {

    @Override
    public ReportPrepaymentRecordVo queryById(Long projId){
        return getVoById(projId, ReportPrepaymentRecordVo.class);
    }

    @Override
    public TableDataInfo<ReportPrepaymentRecordVo> queryPageList(ReportPrepaymentRecordQueryBo bo) {
        PagePlus<ReportPrepaymentRecord, ReportPrepaymentRecordVo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo), ReportPrepaymentRecordVo.class);
        return PageUtils.buildDataInfo(result);
    }

    @Override
    public List<ReportPrepaymentRecordVo> queryList(ReportPrepaymentRecordQueryBo bo) {
        return listVo(buildQueryWrapper(bo), ReportPrepaymentRecordVo.class);
    }

    private LambdaQueryWrapper<ReportPrepaymentRecord> buildQueryWrapper(ReportPrepaymentRecordQueryBo bo) {
        Map<String, Object> params = bo.getParams();
        LambdaQueryWrapper<ReportPrepaymentRecord> lqw = Wrappers.lambdaQuery();
        lqw.like(StrUtil.isNotBlank(bo.getProjName()), ReportPrepaymentRecord::getProjName, bo.getProjName());
        lqw.like(StrUtil.isNotBlank(bo.getCompany()), ReportPrepaymentRecord::getCompany, bo.getCompany());
		lqw.eq(null != bo.getProjId(), ReportPrepaymentRecord::getProjId,bo.getProjId());
		lqw.eq(null != bo.getAdvanceColId(), ReportPrepaymentRecord::getCompanyid,bo.getAdvanceColId());
		lqw.eq(StringUtils.isNoneBlank(bo.getAdvanceNo()), ReportPrepaymentRecord::getAdvanceNo,bo.getAdvanceNo());
        return lqw;
    }

}
